package com.sc.nft.entity.vo.mall;


import com.sc.nft.entity.MallActivityExchange;
import com.sc.nft.enums.task.ActivityTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class OrderConfirmVO {

    @ApiModelProperty("活动Id")
    private Long activityId;
    @ApiModelProperty("活动规格Id")
    private Long specsId;
    @ApiModelProperty("商品售价")
    private String productSalesPrice;
    @ApiModelProperty("订单商品总价格")
    private String totalPrice;
    @ApiModelProperty("订单商品总数")
    private Integer totalNum;
    @ApiModelProperty("邮费")
    private String payPostage;
    @ApiModelProperty("实付金额")
    private String payPrice;

    @ApiModelProperty("支付类型 SALES:品牌直销 EXCHANGE:活动兑换")
    private ActivityTypeEnum activityType;


    @ApiModelProperty("兑换信息")
    private List<MallActivityExchangeOrderConfirmVO> exchangelist;

    @ApiModelProperty("商品信息")
    private List<MallOrderConfirmProductVO> productList;

    public void setProductSalesPrice(BigDecimal productSalesPrice) {
        this.productSalesPrice = productSalesPrice.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setPayPostage(BigDecimal payPostage) {
        this.payPostage = payPostage.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setPayPrice(BigDecimal payPrice) {
        this.payPrice = payPrice.setScale(2,BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setExchangelist(List<MallActivityExchange> activityExchangeList) {
        List<MallActivityExchangeOrderConfirmVO> voList = activityExchangeList.stream()
                .map(activityExchange -> {
                    MallActivityExchangeOrderConfirmVO vo = new MallActivityExchangeOrderConfirmVO();
                    vo.setType(activityExchange.getType());
                    vo.setLinkName(activityExchange.getLinkName());
                    vo.setCostNum(activityExchange.getCostNum());
                    vo.setLinkImage(activityExchange.getLinkImage());
                    // 将其他属性也设置到VO对象中
                    return vo;
                })
                .collect(Collectors.toList());

        this.exchangelist = voList;
    }
}
